﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:odc="clr-namespace:Odyssey.Controls"
        xmlns:mwt="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <ControlTemplate x:Key="DropDownButton" TargetType="{x:Type odc:DropDownButton}">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions> 
            <TextBlock VerticalAlignment="Center" Grid.Column="0" Text="{TemplateBinding Content}" HorizontalAlignment="Left"
                    TextTrimming="CharacterEllipsis" TextWrapping="WrapWithOverflow" />
            <odc:RibbonChrome Grid.Column="1" RenderPressed="{TemplateBinding IsDropDownPressed}" CornerRadius="0,3,3,0" x:Name="PART_DropDown"
                    HorizontalContentAlignment="Center" VerticalContentAlignment="Top"
                    RenderMouseOver="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Margin="-2">
                <ContentPresenter Content="{TemplateBinding DropDownButtonContent}" />
            </odc:RibbonChrome>
            <Popup PlacementTarget="{Binding ElementName=PART_DropDown}" StaysOpen="True" Placement="{TemplateBinding PopupPlacement}"
                    PopupAnimation="{TemplateBinding PopupAnimation}" MaxHeight="{TemplateBinding MaxDropDownHeight}" AllowsTransparency="True"
                    Name="PART_Popup" Focusable="False">
                <mwt:SystemDropShadowChrome Margin="0,0,5,5" CornerRadius="3" Color="#71000000" Name="Shdw" Focusable="False"
                        MinWidth="{TemplateBinding FrameworkElement.ActualWidth}" VerticalAlignment="Stretch">
                    <Border BorderThickness="1" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" Focusable="False"
                            SnapsToDevicePixels="True" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" VerticalAlignment="Stretch"
                            Width="{TemplateBinding DropDownWidth}" CornerRadius="0,0,3,3" ClipToBounds="True" Name="DropDownBorder">
                        <Grid ClipToBounds="True" Focusable="False">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="*" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <ContentPresenter Grid.Row="0" Content="{TemplateBinding DropDownHeader}" Focusable="False"
                                    ContentTemplate="{TemplateBinding DropDownHeaderTemplate}" />
                            <ContentPresenter Grid.Row="2" ClipToBounds="True" Content="{TemplateBinding DropDownFooter}" Focusable="False"
                                    ContentTemplate="{TemplateBinding DropDownFooterTemplate}" />
                            <ScrollViewer Grid.Row="1" x:Name="scroller" VerticalScrollBarVisibility="Auto" SnapsToDevicePixels="True" Focusable="False"
                                    HorizontalScrollBarVisibility="Disabled" CanContentScroll="True" Margin="2">
                                <ItemsPresenter x:Name="items" Focusable="False" KeyboardNavigation.DirectionalNavigation="Contained" />
                            </ScrollViewer>
                        </Grid>
                    </Border>
                </mwt:SystemDropShadowChrome>
                <Popup.Resources>
                    <Style TargetType="{x:Type odc:RibbonButton}">
                        <Setter Property="odc:RibbonBar.Size" Value="Medium" />
                    </Style>
                </Popup.Resources>
            </Popup>
        </Grid>
    </ControlTemplate>

    <Style TargetType="{x:Type odc:DropDownButton}">
        <Setter Property="Template" Value="{StaticResource DropDownButton}" />
    </Style>

</ResourceDictionary>